package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
)

func main() {
	//var users string
	file, err := os.Open("assets/user.json")
	if err != nil {
		fmt.Println("打开json出错" + err.Error())
		return
	}
	defer file.Close()
	data, err := ioutil.ReadAll(file)
	if err != nil {
		fmt.Println("读取json出错" + err.Error())
		return
	}
	var userList UserList
	if err = json.Unmarshal(data, &userList); err != nil {
		fmt.Println("解析json出错" + err.Error())
		return
	}
	for i, obj := range userList.Users {
		fmt.Printf("第%d条, %s  %s  %s  %s  %s %s  %s  %s\n", i, obj.UUID, obj.Username, obj.Password, obj.NickName, obj.HeaderImg, obj.AuthorityId, obj.Phone, obj.Email)
	}
}

type User struct {
	UUID        string
	Username    string
	Password    string
	NickName    string
	HeaderImg   string
	AuthorityId string
	Phone       string
	Email       string
}
type UserList struct {
	Users []*User
}
